package chenji.watcher.listeners;

import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;

import chenji.watcher.Main;

public class WatcherListener implements Listener {
	@EventHandler
	public void event(PlayerQuitEvent e) {
		Main.getWatchGroupManager().playerQuit(e.getPlayer());
		Main.getWatchGroupEditorManager().quitPlayer(e.getPlayer());
	}

	@EventHandler
	public void oxoxoxoxoxoxoooxooxoxoxoxoxxxxoxoxoxoxoxoxoxo(PlayerMoveEvent e) {
		if (e.getFrom().getBlockX() == e.getTo().getBlockX() && e.getFrom().getBlockY() == e.getTo().getBlockY() && e.getFrom().getBlockZ() == e.getTo().getBlockZ()) {
			return;
		}

		if(Main.getWatchGroupManager().contain(e.getPlayer())){
			e.getPlayer().teleport(e.getFrom());
			return;
		}
		
	}
	public void xxooxoxxooxoxoxoxoxoxoxoxoxoxoxoxoxxoxoxoxo(PlayerDeathEvent e){
		Main.getWatchGroupManager().playerQuit(Bukkit.getPlayer(e.getEventName()));
	}
}
